package com.cqc.aiyagril2.utils;

import android.content.Context;
import android.content.SharedPreferences;


/**
 * Created by ${cqc} on 2017/8/9.
 */

public class SpUtil {
    private static SharedPreferences sp;

    public static final String Account="userName";//登陆账号
    public static final String PASSWORD="password";
    public static final String PHONE="photoNumber";
    public static final String FULL_NAME="fullName";//司机姓名
    public static final String SP_NAME="SCMC";//司机姓名


    //存储
    public static void saveString(Context context, String key, String value){
        if(sp == null){
            sp = context.getSharedPreferences(SpUtil.SP_NAME, Context.MODE_PRIVATE);
        }
        sp.edit().putString(key, value).apply();
    }
    //读取
    public static String getString(Context context,String key,String defValue){
        if(sp == null){
            sp = context.getSharedPreferences(SpUtil.SP_NAME, Context.MODE_PRIVATE);
        }
        return sp.getString(key, defValue);
    }


	    public static void clearAllKey(Context context){
        if(sp == null){
            sp = context.getSharedPreferences(SpUtil.SP_NAME, Context.MODE_PRIVATE);
        }
        sp.edit().clear().apply();
    }

    public static void removeKey(Context context,String key){
        if(sp == null){
            sp = context.getSharedPreferences(SpUtil.SP_NAME, Context.MODE_PRIVATE);
        }
        sp.edit().remove(key).apply();
    }
}
